<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="include/header.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>武汉市企业专属空间</title>
<link rel="stylesheet" href="css/style.default.css" type="text/css" />
<!-- 
<link rel="stylesheet" href="css/style.navyblue.css" type="text/css" />-->
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.min.js"></script>
<script type="text/javascript" src="js/modernizr.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery.jgrowl.js"></script>
<script type="text/javascript" src="js/jquery.alerts.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
</head>
<body class="loginpage">
<div class="header">
  		
</div>
<div class="maincontent" >
<div class="maincontentinner">
  <div class="widgetbox box-inverse">
    <h4 class="widgettitle" style="text-align:center">专属空间-用户注册</h4>
    <div class="widgetcontent nopadding">
      <form class="stdform stdform2" method="post" action="">
        <p>
          <label style="text-align:right; margin-top: inherit">手机号：</label>
          <span class="field"><input type="text" id="mobile" class="input-large" placeholder="请输入手机号码" /></span>
        </p>
        <p>
          <label style="text-align:right">密　码：</label>
          <span class="field"><input type="password" id="pwd" class="input-large" placeholder="请输入密码" /></span>
		</p>
        <p>
          <label style="text-align:right">密码确认：</label>
          <span class="field"><input type="password" id="pwd2" class="input-large" placeholder="请再次输入密码" /></span>
		</p>
		<p>
          <label style="text-align:right">图片验证码：</label>
          <span class="field">
          	<input type="text" id="checkcode" class="input-medium" placeholder="请输入图中字符" />
          	<img id="vdimgck" valign="middle" style="cursor: pointer;"  src="getCheckcode.html" onclick="refreshCode();"/>
          </span>
		</p>
		<p>
          <label style="text-align:right">短信验证码：</label>
          <span class="field">
          	<input type="text" id="validcode" class="input-medium" placeholder="请输入短信验证码" />
          	<a id="sendsms" href="javascript:void(0);" onclick="sendsms();" class="btn btn-primary btn-rounded">获取</a>
          	<span id="ct" class="label label-success" style="display:none">(180)</span>
          </span>
		</p>
		
        <p class="stdformbutton" style="text-align:center">
          <a href="javascript:void(0);" onclick="reguser();" class="btn btn-primary btn-rounded"> <i class="iconsweets-user iconsweets-white"></i>  &nbsp; 提&nbsp;&nbsp;交</a>
        </p>
      </form>
    </div>
  </div>
</div>
  <!--footer-->
</div>
<div id="lean_overlay">
	<img src="images/loaders/loader7.gif" alt="" />
</div>
</body>
</html>
<script>
var timer = 180;
function sendsms(){
	jQuery("#lean_overlay").show();
	jQuery.post(
			"sendsmsv.html",
			{
				mobile : jQuery("#mobile").val(),
				checkcode : jQuery("#checkcode").val()
			},
			function(result){
				jQuery("#lean_overlay").hide();
				if(result.result == '10000'){
					jQuery("#sendsms").hide();
					jQuery("#ct").show();
					comptime();
				}
                refreshCode();

				jQuery.jGrowl(result.description);
			}
	);
}

function refreshCode(){
	var rand = Math.round(Math.random() * 100);
	jQuery('#vdimgck').attr("src","getCheckcode.html?tag="+rand).show();
}

function comptime(){
	if(timer == 0){
		jQuery("#ct").hide();
		jQuery("#sendsms").show();
		timer = 180;
	}
	setTimeout(function(){
		jQuery("#ct").html("(" + timer-- +")");
		comptime();
	},1200);
}

function validate(){
	var mobileRegx=/^0{0,1}(1[0-9][0-9])[0-9]{8}$/;
	var pwdRegx = /^[a-zA-Z0-9_]+$/;
	var validMobile = mobileRegx.exec(jQuery("#mobile").val())?true:false;
	if(!validMobile){
		jQuery.jGrowl("请输入正确的手机号");
		return false;
	}
	var validPwd = pwdRegx.exec(jQuery("#pwd").val())?true:false;
	if(!validPwd){
		jQuery.jGrowl("请输入英文字母或数字组成的密码");
		return false;
	}
	if(jQuery("#pwd").val()!=jQuery("#pwd2").val()){
		jQuery.jGrowl("两次密码输入不一致");
		return false;
	}
	if(!jQuery("#validcode").val()){
		jQuery.jGrowl("短信验证码不能为空");
		return false;
	}
	if(!jQuery("#checkcode").val()){
		jQuery.jGrowl("图片验证码不能为空");
		return false;
	}
	return true;
}

function reguser(){
	if(!validate()){
		return;
	}
	jQuery("#lean_overlay").show();
	jQuery.post(
			"reguser.html",
			{
				mobile : jQuery("#mobile").val(),
				pwd : jQuery("#pwd").val(),
				validcode : jQuery("#validcode").val(),
				checkcode : jQuery("#checkcode").val(),
				wxuserid : "${wxuserid}"
			},
			function(result){
				jQuery("#lean_overlay").hide();
				if(result.result == '10000'){
					//跳转到绑定企业页
					window.location.href = "toBindent.html";
				}else{
					refreshCode();
					jQuery.alerts.dialogClass = 'alert-danger';
					jAlert(result.description, '出错了', function(){
		                  jQuery.alerts.dialogClass = null;
		            });
				}
			}
	);
}
</script>